<template>
<view class="integral">
  <view class="int-top" style="background-image:url(./../img/integral_bj.pn);background-size: cover;">
    <view class="int-num">
      <text>{{totalPoint}}</text>
    </view>
    <view class="int-rule">
      <text>1元=3积分  100元=300积分</text>
    </view>
  </view>
  <view class="details">
    <view class="det-title">
      <text>~积分明细~</text>
    </view>
    <view v-for="(item, index) in pointsList" :key="index" class="det-data">
      <view class="fl">
        <view class="det-source">
          <text>购物赠送</text>
        </view>
        <view class="det-time">
          <text>{{item.dateTime}}</text>
        </view>
      </view>
      <view class="det-amount fr">
        <text>+{{item.point}}</text>
      </view>
    </view>
  </view>
</view>
</template>

<script>
// var util = require('../../utils/util.js');
// import request from '../../utils/requestUtils.js';
// import {
//   xcxId,
//   mypoints_url,
// } from "../../utils/data.js";
var app = getApp();

export default {
  data() {
    return {
      pointsList: "",
      totalPoint: ""
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getIndex();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    //获取首页内容
    getIndex: function () {
      var openId = wx.getStorageSync("openid");
      var $this = this;
      var params = {};
      request.POST({
        url: mypoints_url,
        params: params,
        header: request.postHeader,
        success: function (res) {
          // console.log(res)
          var resultData = res.data.data; //console.log(resultData.totalPoint)

          $this.setData({
            pointsList: resultData.pointsList,
            totalPoint: resultData.totalPoint
          });
        },
        fail: function (res) {//失败后的逻辑
        }
      });
    }
  }
};
</script>
<style>
@import "./integral.css";
</style>